package com.situ.service.impl;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.situ.service.CstActivityService;
import com.situ.dao.CstActivityDao;
import com.situ.common.Assist;
import com.situ.entity.CstActivity;
/**
 * CstActivity的服务接口的实现类
 * 
 * @author 胡文 qq:986776
 *
 */
@Service
public class CstActivityServiceImpl implements CstActivityService {
	private final Logger LOG = LogManager.getLogger(this.getClass());

	@Autowired
	private CstActivityDao cstActivityDao;

/**
* 查询....
*/
	@Override
	public List<CstActivity> find(CstActivity value) {

		List<CstActivity> result = cstActivityDao.selectCstActivityByObj(value);

		return result;
	}
@Override
	public List<CstActivity> find2(CstActivity value) {

		List<CstActivity> result = cstActivityDao.selectCstActivityByObj2(value);

		return result;
	}
    /**
* 根据id查询
*/
	@Override
	public CstActivity findOne(Long id) {

		CstActivity result = cstActivityDao.selectCstActivityById(id);

		return result;
	}

/**
* 添加不为空
*/
	@Override
	public CstActivity saveNotNull(CstActivity value) {
		if (value == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行将CstActivity中属性值不为null的数据保存到数据库-->失败:对象不能为空");
			}
			return value;
		}
		if(value.getAtv_place() == null || value.getAtv_title() == null  ){
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行将CstActivity中属性值不为null的数据保存到数据库-->失败:存在不能为空的空值");
			}
			return value;
		}
		int result = cstActivityDao.insertNotNullCstActivity(value);
		if (LOG.isDebugEnabled()) {
			LOG.debug("执行将CstActivity中属性值不为null的数据保存到数据库-->结果:", result);
		}
		return value;
	}
	@Override
    /**
* 修改不为空
*/
	public int updateNotNullById(CstActivity value) {
		if (value == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行通过CstActivity的id更新CstActivity中属性不为null的数据-->失败:对象为null");
			}
			return 0;
		}
		int result = cstActivityDao.updateNotNullCstActivityById(value);
		if (LOG.isDebugEnabled()) {
			LOG.debug("执行通过CstActivity的id更新CstActivity中属性不为null的数据-->结果:", result);
		}
		return result;
	}
    /**
* 删除
*/
	@Override
	public int deleteById(Long id) {
		if (id == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行通过CstActivity的id删除CstActivity-->失败:id不能为空");
			}
			return 0;
		}
		int result = cstActivityDao.deleteCstActivityById(id);
		if (LOG.isDebugEnabled()) {
			LOG.debug("执行通过CstActivity的id删除CstActivity-->结果:", result);
		}
		return result;
	}


}